import {Input} from "antd";
import FormItem from "antd/es/form/FormItem";
import {useDrag} from "react-dnd";
import {MoveDrop} from "../../../hooks/useMoveDrop.tsx";
import {CommonComponentProps} from "../../../../components/editor/interface.ts";
import {removeSetter} from "../../../utils/removeSetter.ts";
import {CSSProperties} from "react";

export interface TextInputProps extends CommonComponentProps {
    id: number;
    name: string;
    styles?: CSSProperties;
    parentId: number;
    children?: any;
    label:any
    type:any,
    rules:any[]
}

const TextInputDev = (props:TextInputProps) => {
    const {id,name, styles } = props;
    const [_,drag] = useDrag({
        type:"TextInput",
        item:{
            id,
            type:name,
            dragType:"move",
        }
    })
    const ComponentProps = removeSetter({...props},["children","parentId"])

    return (
        <div style={styles} data-component-id={id} ref={drag} className={'relative'}>
            <MoveDrop key={name} dropComponentId={id} parentId={props.parentId}  />
            <FormItem>
                <FormItem label={props.label} name={props.name} rules={props.rule} style={{margin: "0",...styles}}>
                    <Input {...ComponentProps}/>
                </FormItem>
            </FormItem>
        </div>
    );
};

export default TextInputDev;